<?php include "config.php" ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Nusantara View</title>
<!-- #BeginLibraryItem "/Library/jquey.lbi" --><script type="text/javascript" src="hebergement_files/jquery.js"></script>
<script type="text/javascript" src="hebergement_files/thickbox.js"></script>
<link rel="stylesheet" type="text/css" href="hebergement_files/thickbox.css" media="screen"><!-- #EndLibraryItem -->
<?php 

function translateLatLngtoAddress($lat,$long,$key)
    {
    $lat=mb_convert_encoding($lat, 'UTF-8',mb_detect_encoding($lat, 'UTF-8, ISO-8859-1', true));
    $long=mb_convert_encoding($long, 'UTF-8',mb_detect_encoding($long, 'UTF-8, ISO-8859-1', true));

    $url="http://maps.google.com/maps/geo?q=$lat,$long&output=csv&sensor=false&key=".$key;
    $response = getGeolocation($url);

    if (substr($response, 0, 3) === '200') {
    return $geo = explode(',', $response);
    }
    return false;
    }
	
	function getGeolocation($url)
    {

    $init = curl_init();
    curl_setopt($init, CURLOPT_URL, $url);
    curl_setopt($init, CURLOPT_HEADER,0);
    curl_setopt($init, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
    curl_setopt($init, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($init);
    curl_close($init);
    return $response;
    }
?>	

<script
src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAlSrsSTN5DgS8ZVvOIMXgaRTNmsdf8oJErPgj8pmeVh4CV1HAChSnA5L1BrGdSJY6TQbpy9Y0lCCvvg"></script>

<script type="text/javascript">
var map;
var geoXml;

function initialize() {
      
      if (GBrowserIsCompatible()) {      
   
        
    map = new GMap2(document.getElementById('map_canvas'));
    geoXml = new GGeoXml('http://nusantaraview.web.id/PETA/coba.php');
    map.addOverlay(geoXml);
    map.setUIToDefault();;
    map.setCenter(new GLatLng(-7.2491667, 112.7508333), 5);
		
      }
    }

</script>

</head>

<body onload="initialize()" onunload="GUnload()">
<div id="top"> 
    
   
  <div id="main"> 
    <div id="content-hebergement" class="content">
      <div id="page"> 
        <p align="center"><img src="nusaview_bg_grad_sidebar2/images/Header.jpg" width="1100" height="250" />
        <div align="center">
          <table width="1102" border="0" background="nusaview_bg_grad_sidebar2/images/nav_baru.png">
            <tr>
              <td width="80" height="21"><a href="../">Home</a></td>
              <td width="227"><a href="peta.php">Menggunakan Kendaraan Pribadi </a></td>
              <td width="170"><a href="index2.php">Data Transportasi Umum </a></td>
              <td width="607"><a href="index.php">Menggunakan kendaraan umum </a></td>
            </tr>
          </table>
          </p>
          <table class="directions">
            <!--<tr>
        <th>Formatted Directions</th><th>Map</th>
      </tr>-->
            <tr>
              <td valign="top"><span style="width: 275px">
                <? $no = 1; $result = mysql_query("SELECT jalur.idt as idt, transport.id as id, transport.Nama as Nama, jalur.lng as lng, jalur.lat as lat, transport.terminal_awal as awal, transport.terminal_akhir as akhir FROM jalur inner join transport on jalur.idt = transport.ID where jalur.cek != 0 order by jalur.cek");
  while($r = mysql_fetch_array($result)) 
   { 
   	$id = $r[id];
   	$nama = $r[Nama];
	$latitude=$r[lat];
    $longitude=$r[lng];
	$awal=$r[awal];
	$akhir=$r[akhir];
	$idt=$r[idt];
	
	$min = mysql_query("SELECT MIN(id) as min from jalur where idt = $idt");
	$min = mysql_fetch_row($min);
	//echo "iniloh".$min[0];
	
	$cek = mysql_query("SELECT id from jalur where idt = $idt && cek != 0");
	$cek = mysql_fetch_row($cek);
	//echo "-".$cek[0];
	
	if ($min[0] == $cek [0]){
	$awal=$r[awal];
	$akhir=$r[akhir];
	} else {
	$awal=$r[akhir];
	$akhir=$r[awal];
	}

	if ($nama != "Jalan")
	{ $guna = "Gunakan "; } else { $guna = "";}
	
	$key= "ABQIAAAAlSrsSTN5DgS8ZVvOIMXgaRRko6GAsd-NuNaX8qRhTW-5iKUrrhQAEyRuTDiP8alMZuDudl0V6ctgMw";
	$data=translateLatLngtoAddress($latitude,$longitude,$key);

	if ($ceks != $id) {
    echo "<pre>";
	echo $no.". ".$guna;
	echo $nama." di ".$awal." ".$data [2].",".$data[3]."<br> menuju ".$akhir;
    echo "</pre>";
	$ceks = $id;
	$no++;
	}

 }
$coba= $_GET['a'] / 1000; 
echo "total jarak ".$coba." kilometer<br>";

$results = mysql_query("SELECT count(*) FROM jalur where cek != 0");
$rows = mysql_fetch_row($results);
$nos = $rows[0];
if ($nos == 0) {
echo "Tidak ada jalur transportasi umum menuju ke tempat yang anda tuju";
}

?>
              </span></td>
              
            <td valign="top"><div id="map_canvas" style="width: 600px; height:600px"></div></td>
              <td></td>
            </tr>
          </table>
        </div>
        <p align="center">&nbsp;</p>
		<form action="latlng.php" method="post" >
          <div align="center">
            <table width="836" bordercolor="#ECE9D8">
              <tr>
                <th width="115" align="right"><div align="left" class="style1">Posisi Anda Sekarang </div></th>
              <td width="300"><div align="left">
                <input name="from" type="text" size="50" />
                Masukkan nama jalan, nama kecamatan,  nama kota dengan tidak ada spasi (contoh : Jalan+Bubutan,+Bubutan,+Surabaya)
                </label>
                </div></td>
              <td width="268"><div align="left" class="style1">Tujuan :</div></td>
              <td width="133"><select name="to">
                <? $result = mysql_query("SELECT * FROM jos_nusaview order by name");
  while($r = mysql_fetch_array($result)) 
   { 
    echo "<option value='$r[latitude],$r[longitude]'>$r[name]</option>";
	
	

 } ?>
                </select>                </td>
            </tr>
              <tr>
                <th>&nbsp;</th>
              <td colspan="7"><div align="left">
                <input name="submit" type="submit" value="Cari Rute" />
                </div></td>
            </tr>
              </table>
          </div>
		</form>
        <p align="center">&nbsp;</p>
        <p align="center">        </p>
</div>
    </div>
  </div>
  <div id="footer"></div>
</div>
<!-- #BeginLibraryItem "/Library/google-analytics.lbi" --><script src="hebergement_files/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-2218183-1";
urchinTracker();
</script><!-- #EndLibraryItem -->
</body>
</html>